package com.xbts.system.controller;

import com.xbts.common.core.web.controller.BaseController;
import com.xbts.common.core.web.domain.AjaxResult;
import com.xbts.common.log.annotation.Log;
import com.xbts.common.log.enums.BusinessType;
import com.xbts.common.security.annotation.RequiresPermissions;
import com.xbts.system.domain.SysThirdBind;
import com.xbts.system.service.ISysThirdBindService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * 第三方公司用户账号信息绑定Controller
 * 
 * @author xbts
 * @date 2023-12-22
 */
@Api(tags = "第三方公司用户账号信息绑定管理")
@RestController
@RequestMapping("/third")
public class SysThirdBindController extends BaseController {

    @Resource
    private ISysThirdBindService sysThirdBindService;

    /**
     * 绑定第三方公司用户账号信息
     */
    @ApiOperation("绑定第三方公司用户账号信息")
    @RequiresPermissions("system:bind:add")
    @Log(title = "绑定第三方公司用户账号信息", businessType = BusinessType.INSERT)
    @PostMapping("/bind")
    public AjaxResult add(@RequestBody SysThirdBind sysThirdBind) {
        return toAjax(sysThirdBindService.bind(sysThirdBind));
    }

    /**
     * 解绑第三方公司用户账号信息
     */
    @ApiOperation("解绑第三方公司用户账号信息")
    @RequiresPermissions("system:bind:remove")
    @Log(title = "解绑第三方公司用户账号信息", businessType = BusinessType.DELETE)
    @GetMapping("/unbind/{id}")
    public AjaxResult unbind (@PathVariable String id) {
        return toAjax(sysThirdBindService.unbind(id));
    }

    /**
     * 获取第三方系统完整路径
     */
    @ApiOperation("获取第三方系统完整路径")
    @ApiImplicitParam(name = "id", value = "第三方系统路径ID", required = true, dataType = "Long", paramType = "path")
    @GetMapping(value = "/fullPath/{id}")
    public void getFullPath(@PathVariable("id") String id, HttpServletResponse response) {
        sysThirdBindService.getFullPath(id, response);
    }

    /**
     * 绑定第三方公司用户账号信息
     */
    @ApiOperation("获取当前用户绑定账号信息")
    @RequiresPermissions("system:bind:query")
    @Log(title = "获取当前用户绑定账号信息", businessType = BusinessType.INSERT)
    @GetMapping("/detail")
    public AjaxResult detail() {
        return success(sysThirdBindService.detail());
    }
}
